package scau.erps.view.decision.sand;

import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

import scau.erps.app.Erps;
import scau.erps.service.ResearchService;
import scau.erps.service.impl.ResearchServiceImpl;

/**
 * 市场开拓盘面模拟面板
 * @author DCJ
 *
 */
public class MarketPanel extends JPanel{
	private static final long serialVersionUID = 1L;
	private JCheckBox[] jck = new JCheckBox[4];
	public MarketPanel(String name){
		JPanel marketPanel = new JPanel(new GridLayout(5,1,0,0));
		marketPanel.setPreferredSize(new Dimension(50,105));
		JLabel label = new JLabel(name);
		marketPanel.add(label);
		for (int i = 0; i < jck.length; i++) {
			int j = i+1;
			jck[i] = new JCheckBox(j+"Y");
			jck[i].setEnabled(false);
			marketPanel.add(jck[i]);
		}		
		if("区域".equals(name)){
			jck[1].setVisible(false);
			jck[2].setVisible(false);
			jck[3].setVisible(false);			
		}
		if("国内".equals(name)){
			jck[2].setVisible(false);
			jck[3].setVisible(false);
		}
		if("亚洲".equals(name)){
			jck[3].setVisible(false);
		}
		this.setCheckBoxValue(name);
		this.add(marketPanel);		
	}
	public void setCheckBoxValue(String name){
		int team_Id = Erps.getCurrentTeam().getId();
		ResearchService researchService = Erps.getIocInstance().get(ResearchServiceImpl.class);
		int j = researchService.findResearchs(team_Id,name);
		for (int i = 0; i < j; i++) {
			jck[i].setSelected(true);
		}
	}
}
